﻿@using System.IO
@model Century.Model.ViewModel.FileExplorerViewModel
@{
    Layout = null;    
}
@{
    string rndName = Model.ExplorerID;
}
<input type="button" id="btnOpenPopup_@(rndName)" value="..." />

@{  Html.Telerik().Window()
        .Name("Window_" + rndName)
        .Title("File Explorer")
        .Content(@<text>
                @Html.Raw(Html.Action("FileTree", "FileExplorer", new { viewModel = Model }).ToHtmlString())
                </text>
        )
        .Width(800)
        .Height(500)
        .Draggable(true)
        .Modal(true)
        .Visible(false)
        .Render();
}

@{ 
    Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text>
                                                        $('#btnOpenPopup_@(rndName)').click(function(e) {
                                                                e.preventDefault();
                                                                $('#@("Window_" + rndName)').data('tWindow').center().open();
                                                             }
                                                        );
                                                        $('#btnSelectImage_@(rndName)').click(function(e) {
                                                                var selectedImagePath = $('#hiddenSelectedImage_@(rndName)').val();
                                                                $('#@(Model.TartgetElementId)').val(selectedImagePath);
                                                                $('#@("Window_" + rndName)').data('tWindow').close();
                                                             }
                                                        );
                                                        var popup = $('#@("Window_" + rndName)').data('tWindow');
                                                     </text>);
}
